from django.db import models
from django.conf import settings
from django.contrib.auth.models import AbstractUser


# Create your models here.
class User(AbstractUser):
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username


class Info(models.Model):

    GENDER_CHOICES = (
        (0,'男'),
        (1,'女')
    )

    name = models.CharField(max_length=16,verbose_name='真人姓名')
    gender = models.SmallIntegerField(choices=GENDER_CHOICES,default=0,verbose_name='性别')
    phone = models.CharField(max_length=11,unique=True,verbose_name='手机号')
    city = models.CharField(max_length=16,verbose_name='现居城市')
    website = models.CharField(max_length=128,verbose_name='个人网站')
    email = models.EmailField(verbose_name='邮箱')
    address = models.CharField(max_length=64,verbose_name='通讯地址')
    technology = models.CharField(max_length=32,verbose_name='擅长技术')
    work_experience = models.TextField(verbose_name='工作经验')
    education_experience = models.TextField(verbose_name='教育经历')
    school = models.CharField(max_length=16,verbose_name='毕业院校',null=True)
    company = models.CharField(max_length=16,verbose_name='所在公司',null=True)
    birthday = models.DateField(verbose_name='出生日期',null=True)
    image = models.CharField(verbose_name='个人头像',null=True,max_length=128)
    user = models.OneToOneField(to='User')


    class Meta:
        db_table = 'person_info'
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name




class information(models.Model):
    user = models.ForeignKey(User, verbose_name='用户id', on_delete=models.CASCADE)
    username = models.CharField(verbose_name='真是姓名', max_length=32)
    signature = models.IntegerField(verbose_name='手机号')
    city = models.CharField(verbose_name="现居城市",max_length=128)
    website = models.CharField(verbose_name="个人网址",max_length=64)
    email = models.CharField(verbose_name="邮箱",max_length=64)
    site = models.CharField(verbose_name="通讯地址",max_length=128)
    good_technology = models.CharField(verbose_name="擅长技术",max_length=128)
    experience = models.TextField(verbose_name='工作经历')

    class Meta:
        db_table = 'tb_users_information'
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name